const express = require('express');
const mongo = require('../dataBase/users');
const router = express.Router();

router.get('/', (req, res) => {
    let searchId = req.query.searchId;
    mongo.Users.findOne({ userId: searchId }, (err, docu) => {
        if (err) {
            res.send({ status: false });
            return
        }
        if (docu == null) {
            res.send({ status: false });
            return
        }
        console.log('查询用户内容:' + docu);
        var data = {
            status: true,
            result: {
                userId: docu.userId,
                avatarImg: docu.avatarImg,
                name: docu.name
            }
        }
        res.send(data);
    }).catch(err => {
        console.log(err);
        res.send({ status: false });
    })
})

module.exports = router;